<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/taglib.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>    
    <title>税收分类编码</title>
    <style type="text/css">
			 .numericInput {
			text-align:right;
		 	}
		</style>
	<%@ include file="/WEB-INF/jsp/include.jsp"%>
	
	<script type="text/javascript">
	
		var path = "${path}";
		var params=new Object();
		var url=path+"/system/taxclasscode/queryByPage";
		var ysxm = new Object();
		var numeric_options_bl_2 = {
				aSign: '%',
				pSign: 's',
				vMin: '0',
				vMax: '100'					
		};
		$(function(){
			//设置AjaxLoading
//			setAjaxLoading();
//			 $(".numericInput").autoNumeric('init', numeric_options_bl_2);
			var grid=$("#tt");
			initGrid(grid);
		});

		//初始化表格和数据
		function initGrid(grid) {
		    var columns=[
			            { field: "taxClassId", title: "ID", hidden: true, align: "left", sortable: false, resizable: true, width: 80},		
			            { field: "taxClassCode", title: "税收分类编码", align: "left",halign: "center", sortable: false, resizable: true, width: 160 },
			            { field: "productName", title: "商品名称", align: "left",halign: "center", sortable: false, resizable: true, width: 185 },
			            { field: "taxAbleCode", title: "应税项目", align: "left",halign: "center", sortable: false, resizable: true, width: 185 },
			            { field: "taxRateGeneral", title: "一般增值税税率", align: "left",halign: "center", sortable: false, resizable: true, width: 295},
			            { field: "taxRateSimple", title: "简易增值税税率", align: "left",halign: "center", sortable: false, resizable: true, width: 345}
			        ];
		    initPageGrid(grid, params, url,columns,"#tb");
		    var gridOptions = $("#tt").datagrid("options");
		    btnQuery();

		}
		
		//查询按钮
		function btnQuery(){
			params.taxClassCode = $("#taxClassCode").val();
			
            if($("#taxRate").val() != null && $("#taxRate").val()  != ''){
                
                if(parseFloat($("#taxRate").val())>=0){
                    params.taxRate = $("#taxRate").val()/100;
				}else{
                    //$.messager.alert('友情提醒','税率请输入数字','info',function(){
                    $.messager.alert('信息','税率请输入数字','info',function(){
                        $('#taxRate')[0].focus();
                    });
				}
                

            }else{
                params.taxRate = '';
            }

            params.pageNumber =1;
			var grid=$("#tt");
    		getPage(grid,params,url);
		}
		function btnClear(){
			$("#taxClassCode").val("");
			$("#taxRate").val("");
			btnQuery();
		}
		    
		//新增
		function btnAdd(){
			layer.open({
				type: 2,
				title: "税收分类编码 - 添加",
				shadeClose: false,
				shade: 0.3,
				area: ["550px","210px"],
				
				content: '${path}/system/taxclasscode/toAdd'
			});
		}
		
		//修改
		function btnUpdate(){
			var row =$("#tt").datagrid("getSelected");
			if(row == null){
				//$.messager.alert("友情提醒","请选择一条记录~");
				$.alert("pick", "info", "");
				return ;
			}
			
			layer.open({
				type: 2,
				title: "税收分类编码 - 修改",
				shadeClose: false,
				shade: 0.3,
				area: ["550px","210px"],
				
				content: '${path}/system/taxclasscode/toUpdate?taxClassId='+row.taxClassId
			});
		}
		
		//查看
		function btnView(){
			var row =$("#tt").datagrid("getSelected");
			if(row == null){
				//$.messager.alert("友情提醒","请选择一条记录~");
				$.alert("pick", "info", "");
				return ;
			}
			
			layer.open({
				type: 2,
				title: "税收分类编码 - 查看",
				shadeClose: false,
				shade: 0.3,
				area: ["550px","210px"],
				
				content: '${path}/system/taxclasscode/toView?taxClassId='+row.taxClassId
			});
		}
		
		//删除
		function btnDel(){
			var rows = $('#tt').datagrid('getSelections');
		    if (rows.length == 0) {
		        //$.messager.alert("友情提醒", "请先选择一个项目！", "info");
		        $.alert("pick", "info", "");
		        return;
		    }	
			var rowData = rows[0];
			var param = new Object();
			param.taxClassId = rowData.taxClassId;
			//$.messager.confirm("友情提醒", "该删除后将不可恢复，是否删除？", function (b) {
			$.messager.confirm("问题", "请确认是否要删除？", function (b) {	
	            if (b) {
	    			$.ajax({
		        		type:"POST",
		       			url:path+'/system/taxclasscode/delete',
		        		data:param,
		       			dataType:"json",
		       			async: false,
		       			success:function callback(data){
		       				var analyMsg = data;
		       				if(analyMsg.code!="0000"){
		         				//$.messager.alert('友情提醒',analyMsg.msg,'info',function(){});
		       					$.alert("delete", "error", "");
		         			}else{
		         				btnQuery();
		        			}
		       			}
		       		});	
	            }
	        });						
       	}
		
	function callback_selectZzsYsxm(data){
		ysxm = data;
	}
	
	
		    
	</script>
  </head>
  
  <body  style="margin:0px; padding:0px;" >
	<%@ include file="/WEB-INF/jsp/loading.jsp"%>
	<div class="easyui-layout" fit="true">
		<div region="center" style="padding: 5px;" border="false">
			<div class="easyui-layout" fit="true" border="false">
				<div id="divNorth" region="north" title="查询条件" border="true"
					 noheader="false"
					 style="padding: 5px; height: 70px; background: none repeat scroll 0 0 #EFEFEF;">
			        <table>
			        		<tr>
			        		 <td align="right">税收分类编码：</td><td><input id="taxClassCode" name ="taxClassCode" type="text" style="width:180px" class="query_input"/></td>
			        		<td align="right">税率：</td><td><input id="taxRate"  type="text" style="width:180px" class="query_input numericInput"/><span>%</span></td>
			     
			        			<td colspan="2">
								<input class="search-btn-blue" type="button" onclick="btnQuery();" value="查询">
								<input class=" search-btn-gray" type="button" onclick="btnClear();" value="重置">
							</td>	
			            </tr>
			        </table>			
				</div> 
				<div region="center" title="税收分类编码" border="true">
					<table id="tt" title="" border="false"></table>
				</div>
			</div>
		</div>
	</div>
	<div id="tb" style="padding: 1px; height: auto; display: none;">
        <div>
        	<a id="btn_addNode_tb" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain="false" onclick="btnAdd()">新增</a>
        	<a id="btn_editNode_tb" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-edit" plain="false" onclick="btnUpdate()">修改</a>
        	<a id="btn_removeNode_tb" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-remove" plain="false" onclick="btnDel()">删除</a>
        	<a id="btn_removeNode_tb" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-search" plain="false" onclick="btnView()">查看</a>
        </div>
    </div>
  </body>
</html>
